#ifndef GPU_H
#define GPU_H

#include "color.h"
#include "pipeline.h"

typedef struct
{
    s8 base;
    u32 vertType;
    s8 lightingEnable;
    s8 lightEnable[4];
    s8 textureMapEnable;
    u32 boneMatrixNumber;

    u8 worldmtxnum;
    u8 viewmtxnum;
    u8 projmtxnum;
    u8 texmtxnum;

    s8 reversenormals;

    u32 materialupdate;
    u32 materialemissive;
    u32 materialdiffuse;
    u32 materialspecular;
    float materialambient[4];
    float materialspecularcoef;

    u32 ambientcolor;
    u32 ambientalpha;

    u32 ltype[4];

    u32 texAddr[8];
    u32 texBufWidth[8];
    u16 texWidth[8];
    u16 texHeight[8];

    u32 texshade; 
    u32 texformat;
    u32 texfilter;
    u32 texwrap;
    u32 clearmode;
    u8 texSwizzle;

    u8 mipmapShareClut;
    u32 numMipmaps;

    u8 clutMode;
    u8 clutShift;
    u8 clutMask;
    u8 clutStart;
    u8 clutBlocks;
    u32 clutAddr;

    u32 vertexAddr;
    u32 indexAddr;

    s8 textureChanged;
    s8 projChanged;

    float uScale, vScale;
    float uOff, vOff;
    float lightpos[4][3];
    float lightdir[4][3];
    float lightatt[4][3];
    Color4 lightColor[3][4]; /* ADS */
    float morphWeights[8];
    
    u16 paletteMem[256 * 2];

    s32 xscale, yscale;
    float zscale, zpos;
    s32 minz, maxz;

    s8 cullFaceEnabled;

    u32 frameBufferLow;
    u32 frameBufferHigh;
    u32 frameBufferWidth;

    s32 xpos, ypos;
    s32 offsetx, offsety;

    u8 texMap;

    u32 psubs, psubt;

    float sfix[4], dfix[4];
    u8 srcfunc, dstfunc;
} GPUgstate;

float getFloat24(s32 data);
float binToFloat(s32 bits);

extern GPUgstate gstate;

#endif

